package exer3;

import java.util.Scanner;

/**
 * Date:2025/2/23
 * Author：zhouzhou
 * Description:
 */
public class Login {
    public static void main(String[] args) {
        User[] arr = new User[3];
        arr[0] = new User("tom", "123456");
        arr[1] = new User("lop", "abcd");
        arr[2] = new User("zhouzhou", "zhouzhou");

        Scanner sc = new Scanner(System.in);
        System.out.println("请输入用户名:");
        String uName = sc.nextLine();
        System.out.println("请输入密码");
        String upwd = sc.nextLine();
            int i;
        for ( i = 0; i < arr.length; i++) {
            if (arr[i].getName().equals(uName)) {//用户名正确
                if (arr[i].getPassword().equals(upwd)) {
                    System.out.println("登录成功!!");
                } else {
                    System.out.println("密码错误.");
                }
                break;
            }
        }
        if(i==arr.length) System.out.println("没有该用户");
    }
}

